package typechecker.ast.type;

import typechecker.ast.Context;

public class ForallType extends TypeExpression{
	private TypeVariable quant;
	private TypeExpression body;
	
	public ForallType(TypeVariable quant, TypeExpression body) {
		this.quant = quant;
		this.body = body;
	}

	@Override
	public String preetyPrint() {
		return "\\/" + quant.preetyPrint() + "." + body.preetyPrint();
	}
	
	public TypeExpression getBody() {
		return body;
	}
	
	public TypeVariable getQuant() {
		return quant;
	}
	
	@Override
	public TypeExpression freshCopy(Context<TypeVariable> ctx) {
		TypeVariable clonedQuant = (TypeVariable) new TypeVariable(quant.getName());
		ctx.push(clonedQuant);
		TypeExpression ft =  new ForallType(clonedQuant, body.freshCopy(ctx));
		ctx.pop();
		return ft;
	}	
}
